package com.htbb.base.util;
import java.io.IOException;

import net.spy.memcached.AddrUtil;
import net.spy.memcached.BinaryConnectionFactory;
import net.spy.memcached.MemcachedClient;

public class MemCacheUtil {
    private String namespace = "s:v1";

    private  MemcachedClient cache = null;;

    public  String cacheUrl;

    public MemCacheUtil(String cacheUrl) {
    	try {
        	cache =  new MemcachedClient( new BinaryConnectionFactory(), AddrUtil.getAddresses(cacheUrl));
        } catch (IOException e) {
            e.printStackTrace();
        }
	}

    public Object get(String type, Object key) {
        Object o = null;
        try {
            o = cache.get(namespace + type + key);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if(o != null) {
        }
        return o;
    }

    public String getNamespace() {
        return namespace;
    }

    public void setNamespace(String namespace) {
        this.namespace = namespace;
    }

	public MemcachedClient getCache() {
		return cache;
	}

	public void setCache(MemcachedClient cache) {
		this.cache = cache;
	}

	public String getCacheUrl() {
		return cacheUrl;
	}

	public void setCacheUrl(String cacheUrl) {
		this.cacheUrl = cacheUrl;
	}

}



